/* This file is part of xREL
 *
 * Copyright (C) 2012 Timo Zimmermann <xrel@timozimmermann.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

import QtQuick 1.1
import com.xrel 1.0
import "../components"
import "../js/HelperLib.js" as Helper

Item {
    id: root
    width: parent.width - 6
    anchors.horizontalCenter: parent.horizontalCenter
    height: 92

    ListItemHighlight { id: highlight }

    Image {
        anchors.verticalCenter: titleLabel.verticalCenter
        anchors.right: parent.right
        anchors.rightMargin: 6
        source: "../images/us_flag.png"
        visible: flags_english !== ""
    }

    Rectangle {
        id: typeRect
        anchors.top: parent.top
        anchors.left: parent.left
        height: parent.height
        width: 24
        color: "black"
        radius: 4

        Label {
            id: typeLabel
            anchors.centerIn: parent
            rotation: -90
            text: "Type"
            color: "white"
            font.pixelSize: 14
        }
    }

    Image {
        id: typeIcon
        anchors.top: titleLabel.top
        anchors.topMargin: 8
        anchors.left: typeRect.right
        anchors.leftMargin: 6
        source: "../images/cd_nocat.png"
    }

    Label {
        id: titleLabel
        anchors.top: parent.top
        anchors.left: typeIcon.right
        anchors.leftMargin: 6
        text: ext_info_title
    }

    Label {
        id: dirNameLabel
        anchors.top: titleLabel.bottom
        anchors.left: typeRect.right
        anchors.leftMargin: 6
        text: dirname
        font.pixelSize: 20
        color: "darkgray"
    }

    Label {
        id: info
        anchors.top: dirNameLabel.bottom
        anchors.left: typeRect.right
        anchors.leftMargin: 6
        text: Helper.formatDateTime(time, "dd.MM.yy | hh:mm") + " - " + size_number + " " + size_unit
        font.pixelSize: 20
        color: "darkgray"
    }

    MouseArea {
        anchors.fill: parent
        onPressed: highlight.opacity = 1.0
        onReleased: highlight.opacity = 0.0
        onPositionChanged: highlight.opacity = 0.0
        onClicked: parent.ListView.view.showReleaseSceneInfo(id)
    }

    Item {
        state: ext_info_type
        states: [
            State {
                name: "movie"
                PropertyChanges { target: typeLabel; text: "MOVIE" }
                PropertyChanges { target: typeRect; color: "cyan" }
            },
            State {
                name: "tv"
                PropertyChanges { target: typeIcon; source: "../images/cd_tv.png" }
                PropertyChanges { target: typeLabel; text: "TV" }
                PropertyChanges { target: typeRect; color: "brown" }
            },
            State {
                name: "console"
                PropertyChanges { target: typeIcon; source: "../images/cd_console.png" }
                PropertyChanges { target: typeLabel; text: "CONSOLE" }
                PropertyChanges { target: typeRect; color: "purple" }
            },
            State {
                name: "game"
                PropertyChanges { target: typeIcon; source: "../images/cd_game.png" }
                PropertyChanges { target: typeLabel; text: "GAME" }
                PropertyChanges { target: typeRect; color: "#808000" }
            },
            State {
                name: "xxx"
                PropertyChanges { target: typeIcon; source: "../images/cd_xxx.png" }
                PropertyChanges { target: typeLabel; text: "XXX" }
                PropertyChanges { target: typeRect; color: "red" }
            },
            State {
                name: "software"
                PropertyChanges { target: typeLabel; text: "Software" }
                PropertyChanges { target: typeRect; color: "black" }
            }
        ]
    }

}
